set( CMAKE_SYSTEM_NAME Generic )

set( CMAKE_C_COMPILER_FORCED TRUE CACHE INTERNAL "" )
set( CMAKE_CXX_COMPILER_FORCED TRUE CACHE INTERNAL "" )
set( CMAKE_C_COMPILER_WORKS TRUE CACHE INTERNAL "" )
set( CMAKE_CXX_COMPILER_WORKS TRUE CACHE INTERNAL "" )
set( CMAKE_C_COMPILER_ID_RUN TRUE CACHE INTERNAL "" )
set( CMAKE_CXX_COMPILER_ID_RUN TRUE CACHE INTERNAL "" )

set( CCPATH "D:/TASKING" )

#if ( UNIX )
#  set( OS_PLATFORM linux )
#  set( SHELL_SUFFIX sh)
#else ()
  set( OS_PLATFORM windows )
  set( SHELL_SUFFIX cmd)
#endif ()
#set(CMAKE_MAKE_PROGRAM  "D:/TASKING/ctc/bin")

set( CMAKE_C_COMPILER "${CCPATH}/ctc/bin/cctc.exe" )
set( CMAKE_CXX_COMPILER "${CCPATH}/ctc/bin/cctc.exe" )
#set( CMAKE_C_COMPILER_VERSION "6.2.r2" )
#set( CMAKE_C_COMPILER_VERSION "6.3r1" )

#set( CMAKE_USER_MAKE_RULES_OVERRIDE ON )
#Todo: this is not working. object file is always *.obj
#overrided by CMakeCInformation.cmake
#set( CMAKE_C_OUTPUT_EXTENSION .o )
set( CMAKE_C_OUTPUT_EXTENSION_REPLACE ON )
set( CMAKE_ASM_OUTPUT_EXTENSION_REPLACE ON )

set( CC "${CCPATH}/ctc/bin/cctc.exe" )
set( CXX "${CCPATH}/ctc/bin/cctc.exe" )
set( CMAKE_LINKER "${CCPATH}/ctc/bin/ltc.exe" )
set( CMAKE_AR "${CCPATH}/ctc/bin/artc.exe" CACHE FILEPATH "Archiver" )

set( CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1 )
set( CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1 )
set( CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1 )

# Without "-f" the responsible file flag will be "@" which is not handled by tasking compiler
# So we need to set them as below
set( CMAKE_C_RESPONSE_FILE_LINK_FLAG "-f " )
set( CMAKE_C_RESPONSE_FILE_FLAG "-f " )
set( CMAKE_C_OUTPUT_EXTENSION ".o" )
set( CMAKE_START_TEMP_FILE "-f " )

set( CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> <SOURCE>" )
set( CMAKE_C_LINK_EXECUTABLE "'${CMAKE_LINKER}' <OBJECTS> <LINK_LIBRARIES> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> --output=<TARGET>.elf:ELF --output=<TARGET>.hex:IHEX --output=<TARGET>.sre:SREC" )

# Don't know how to set this on project level (not in toolchain file)
set( CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -r -c -v <LINK_FLAGS> <TARGET> <OBJECTS>" )
set( CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> --replace <LINK_FLAGS> <TARGET> <OBJECTS>" )
set( CMAKE_C_ARCHIVE_FINISH "" )

# search for programs in the build host directories
# search for libraries and headers in the target directories
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH )
